import { Npc } from "../npc";

// 关于Npc最基础的控制，如杀害、切磋、赠礼
export class BasicNpc extends Npc{
	// 当玩家对npc操作杀害操作是否将状态改为战斗状态
	getIsDieToMode1(){
		return true;
	}

	getControls() {
		let controls = [
			{ key: 'Dialogue', text: "对话" },
			{ key: "Die", text: "杀害" },
			{ key: "Duel", text: "切磋" },
			{ key: 'Gifts', text: "赠礼" },
			{ key: 'Recruit', text: "招募" },
		];

		return controls;
	}

	/**
	 * --------------------   控制方法   ----------------------
	 */

	getControlDialogue(){
		this.root.hud.parts.dialogue.handleShowDialogue(this);
	}

  getControlDie(){
		// 当你有了杀心，那么这个npc将直接变为战斗状态，并且警惕值拉满
		if(this.getIsDieToMode1()){
			this.saveNpcData((peopleAttr, attr) => {
				attr.mode = 1;
				attr.battleProgress = 90;
			})
		}

		this.root.battleMgr.newBattle(this);
  }

	getIsDieConfirm(){
		return true;
	}

  getControlDuel(){
    console.log('Duel');
  }

	getIsDuelConfirm(){
		return true;
	}

  getControlGifts(){
    console.log('Gifts');
  }

	getControlRecruit(){
		this.saveNpcData((peopleAttr, attr) => {
			attr.isLive = false;
		})
		this.root.playerData.troops.push(this.people);
		this.root.hud.parts.playerPage.drawPlayerPanel();
		this.root.hud.parts.worldPage.renderNpc();
		this.root.message('alert', `招募<${this.getName()}>`);

		this.root.savePlayerData();
	}
}